Direct Linux boot: Support booting non-relocatable Linux kernels.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 1 Feb 2008 11:16:37 +0000 (11:16 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 1 Feb 2008 11:16:37 +0000 (11:16 +0000)
commit042397126c8e75019b4c74483d7bfdff7f501a0a
treeb5a27ec4a9c2f680b34cb155ff0eddc72a11c4dd
parentbd03fbb90e6bfcbed2f71a4ef815840f86e66136
Direct Linux boot: Support booting non-relocatable Linux kernels.

This patch introduces a hack to make non-relocatable kernels
bootable too. Non-relocatable kernels absolutely want to run
at 0x100000 and are not at all happy about being at 0x200000.
Fortunately, thanks to crazy programs like LOADLIN, Linux has
a couple of hooks in its boot process which can be used to
play games. The 'code32_switch' hook is executed immediately
following the switch to protected mode.

So, this patch installs a hook at 0x200000+kernel_size. The hook
is hand crafted assembly which sets up all the segments as needed,
then essentially does memmove(0x100000,0x200000,kernel_size) and
finally does an unconditional jmp to 0x100000.

Amazingly this actually really does work. It has been successfully
tested with RHEL-2.1 and Fedora Core 6 install kernels on i386, and
Fedora Core 6 and 7 kernels on x86_64.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tools/ioemu/hw/pc.c